<%@page contentType="text/html; charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<html>
	<head>
		<title>角色权限授予</title>
		<script type="text/javascript" src="${ctxPath}/resource/common/js/core/selectUtil.js"></script>
		<script type="text/javascript">
			//保存授权的角色id
			function saveSelRoleIds(){
				var _selected=$("#_selected")[0];
				var selRoleIds=$("#selRoleIds")[0];
				for(var i=0;i<_selected.options.length;i++){
					if(i>0){
						selRoleIds.value+=",";
					}
					selRoleIds.value+=_selected.options[i].value;
				}
			}
		</script>
	</head>
	<body>
		<div class="post">
				<div class="story">
					<h3>角色[${appUser.username}]权限授予</h3>
				</div>
		</div>
		<div id="div-data">
			<form action="grantRole.do?cmd=saveGrantRole" method="post">
			<table cellpadding="0" cellspacing="0" border="1" width="98%" align="center">
				<thead>
					<tr>
						<th width="47%">未选择角色</th>
						<th width="6%"></th>
						<th width="47%">已选择角色</th>
					</tr>
				</thead>
				<tbody>
					<tr class="even">
						<td>
							<select id="_unselected" name="_unselected" style="width:96%;height:340px" 
							multiple="multiple" ondblclick="addSelect(this,$('#_selected')[0])">
								<c:forEach items="${unselectedRoles}" var="role">
									<option value="${role.roleId}">${role.roleName}</option>	
								</c:forEach>
							</select>
						</td>
						<td  align="center">
							<input type="button" value=" &gt; " onclick="addSelect($('#_unselected')[0],$('#_selected')[0]);">
							<div class="blank8"></div>
							<input type="button" value="&gt;&gt;" onclick="fnMoveAllOptions($('#_unselected')[0],$('#_selected')[0]);">
							<div class="blank8"></div>
							<input type="button" value=" &lt; " onclick="addSelect($('#_selected')[0],$('#_unselected')[0]);">
							<div class="blank8"></div>
							<input type="button" value="&lt;&lt;" onclick="fnMoveAllOptions($('#_selected')[0],$('#_unselected')[0]);">
						</td>
						<td>
							<select id="_selected" name="_selected" style="width:96%;height:340px" multiple="multiple"
							ondblclick="addSelect(this,$('#_unselected')[0])">
								<c:forEach items="${userAccount.roles}" var="role">
									<option value="${role.roleId}">${role.roleName}</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<td colspan="3" align="center">
						<input type="hidden" name="userId" value="${param['userId']}"/>
						<input type="submit" value="保 存" class="save" onclick="saveSelRoleIds();"/>
						<input type="hidden" id="selRoleIds" name="selRoleIds" value=""/>
						&nbsp;
						<input type="button" value="取 消" class="cancel" onclick="history.back(-1);"/>
					</td>
				</tbody>
			</table>
		</div>
	</body>
</html>